package com.baizhi.cmfz.service.impl;

import com.baizhi.cmfz.dao.CmfzLogDao;
import com.baizhi.cmfz.entity.CmfzLog;
import com.baizhi.cmfz.service.CmfzLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class CmfzLogServiceImpl implements CmfzLogService {
    @Autowired
    private CmfzLogDao cmfzLogDao;
    @Override
    public Map selectByPageCmfzLog(int page, int limit, String content, String field) {
        Map map=new HashMap();
        int ofset=(page-1)*limit;

        if (content != null && !content.equals("")){
            content="%"+content+"%";
        }else {
            content=null;
        }

        if (field == null || field.equals("")){
            field=null;
        }


        List<CmfzLog> cmfzLogs = cmfzLogDao.selectByPageCmfzLog(ofset, limit, content, field);
        int count = cmfzLogDao.selectTotalCountCmfzLog(content, field);
        map.put("data",cmfzLogs);
        map.put("count",count);
        map.put("code",0);
        map.put("msg","");



        return map;
    }
}
